Get a list of installed python modulesΒΆ
Get a list of locally installed python modules.
import pkg_resources
dists = [d for d in pkg_resources.working_set]
def getKey(elem):
return elem._key
for d in sorted(dists, key=getKey):
print("%s==%s" % (d._key, d._version))
Output:
[alabaster==0.7.12
babel==2.6.0
beautifulsoup4==4.6.3
certifi==2018.8.24
chardet==3.0.4
colorama==0.4.0
cssselect==1.0.3
cycler==0.10.0
decorator==4.3.0
docutils==0.14
guzzle-sphinx-theme==0.7.11
html5lib==1.0.1
idna==2.7
imagesize==1.1.0
jinja2==2.10
kiwisolver==1.0.1
lxml==4.2.5
markupsafe==1.0
matplotlib==3.0.0
networkx==2.2
numpy==1.15.2
packaging==18.0
pillow==5.2.0
pip==18.1
pygments==2.2.0
pyparsing==2.2.2
python-dateutil==2.7.3
pytz==2018.5
requests==2.19.1
setuptools==39.0.1
six==1.11.0
snowballstemmer==1.2.1
sphinx==1.8.1
sphinxcontrib-inlinesyntaxhighlight==0.2
sphinxcontrib-websupport==1.1.0
sqlalchemy==1.2.12
unicodecsv==0.14.1
urllib3==1.23
urlopen==1.0.0
webencodings==0.5.1
]